import { registerPortletProvider } from '@ibiz-template/runtime';
import { withInstall } from '@ibiz-template/vue3-util';
import { App } from 'vue';
import { PortletPlugin } from './portlet';
import { PortletPluginProvider } from './portlet.provider';

export * from './portlet';

export const IBizPortletPlugin = withInstall(PortletPlugin, function (v: App) {
  // 全局注册门户部件插件组件
  v.component(PortletPlugin.name, PortletPlugin);
  // 全局注册门户部件适配器，PORTLET_CUSTOM是插件类型，R9PortletPluginId是插件标识
  registerPortletProvider(
    'PORTLET_CUSTOM_R9PortletPluginId',
    () => new PortletPluginProvider(),
  );
});

export default IBizPortletPlugin;
